<!DOCTYPE html>
<html>
<head>
    <title>简单聊天室demo</title>
    <meta charset="utf-8">
    <script type="text/javascript">
        var webSocket = new WebSocket("ws://127.0.0.1:9501");
        webSocket.onopen = function(event)
        {
            webSocket.send("客户端已经连接到服务器");
        }
        webSocket.onmessage = function(event)
        {
            console.log(event.data);
        }
    </script>
</head>
<body>
    <input type="text" id="content">
    <button onclick="webSocket.send(document.getElementById('content').value);">发送
    </button>
</body>
</html>